﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace CannedHeater.View.Converters
{
    /// <summary>
    /// Converts a number to boolean.
    /// null -> false
    /// 0 -> false.
    /// _ -> true.
    /// (Usage suggestion: enable element only if some count is not 0)
    /// </summary>
    public class NumberToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return false;
            }
            else
            {
                int num = (int)value;
                if (num == 0) return false;
                else return true;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
